package binary_search.leetcode_35;

public class Test {
    public static void main(String[] args) {
        int[] nums = new int[]{1};
        int i = searchInsert(nums, 1);
        System.out.println(i);
    }
    public static int searchInsert(int[] nums, int target) {
        if(nums == null || nums.length == 0){
            return 0;
        }
        int len = nums.length;
        for(int i = 0; i < len - 1; i++){
            if(nums[i] >= target){
                return i;
            }else if(nums[i] < target && nums[i + 1] > target){
                return i + 1;
            }
        }
        return len;
    }
}
